NDC File Exploration with NailFile

This notebook explores the National Drug Code file from FDA.gov. The zip file was last available here.

In order to run this example, download the NDC.zip file and put product.txt in the same folder as this notebook.


In [1]:
# imports
import sys
sys.path.append('..')
from IPython.display import HTML
from nailfile import readers
from nailfile import nailfile

In [2]:
# run this to load the file into an in-memory SQLite database
reader = readers.CsvReader('product.txt', table_name='products', delimiter='\t')
loader = nailfile.DataLoader()
ds = loader.load(reader)

In [3]:
# query away!
# get the top drug manufacturers
sql = """
select LABELERNAME, count(*) from products group by LABELERNAME order by 2 desc limit 10
"""
results = ds.fetchall(sql)
h = HTML(nailfile.to_html(results))
h


Out[3]:
LABELERNAMEcount(*)
Nelco Laboratories, Inc.2362
REMEDYREPACK INC.2248
Cardinal Health1847
Physicians Total Care, Inc.1789
ALK-Abello, Inc.972
Antigen Laboratories, Inc.896
Rebel Distributors Corp865
PD-Rx Pharmaceuticals, Inc.793
Mylan Pharmaceuticals Inc.788
Bryant Ranch Prepack746

In [ ]: